import Vue from 'vue';
import Router from 'vue-router';
import { UserSrv } from '../modules/user/user.service';

import UserRouters from '../modules/user/user.router';
import DepartmentRouters from '../modules/department/department.router';
import RoleRouters from '../modules/role/role.router';
import VersionRouters from '../modules/version/version.router';
import AlarmRouters from '../modules/alarm/alarm.router';
import SettingRouters from '../modules/setting/setting.router';

Vue.use(Router);

let router = new Router({
	routes: [
		...UserRouters,
		...DepartmentRouters,
		...RoleRouters,
		...VersionRouters,
		...AlarmRouters,
		...SettingRouters
	]
});

////router.beforeEach(RouterAuthHook);
//router.beforeEach((route, redirect, next) => {
//	if(Notification){
//		console.log(Notification);
//	}
//	next();
//});
//
//function getQueryString(name) {
//	var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
//	var r = window.location.search.substr(1).match(reg);
//	if(r != null) {
//		return unescape(r[2]);
//	}
//	return null;
//}
//
//function setToken() {
//	if(getQueryString('code')) {
//		window.localStorage.setItem('token', getQueryString('code'));
//		//url重定向
//		window.location = window.location.origin;
//	}
//	//调试
//	if(!window.localStorage.getItem('token')||window.localStorage.getItem('token')!=='a7f54cad-e7a3-42f6-be20-7401c7b66300') {
//		window.localStorage.setItem('token', 'a7f54cad-e7a3-42f6-be20-7401c7b66300');
//	}
//}

function GlobalRouterPlugin() {}
GlobalRouterPlugin.install = function(Vue, options) {
	Vue.getRouter = function() {
		return router;
	};
};
Vue.use(GlobalRouterPlugin);

export {
	router
};